<?php

class MemberBaseController extends Controller
{
    /**
     * @var string the default layout for the controller view. Defaults to '//layouts/column1',
     * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
     */
    public $layout    = '//member/member_column';
    public $themeName = 'basic'; 

    // url manager
    public $url;


    /*
        smarty view object
    */
    //public $smarty;
    
    /*
        template display key
    */
    private $_displayKey = YII_DEFAULT_KEY;
    function setDisplayKey( $key=YII_DEFAULT_KEY ) 
    {
        $this->_displayKey = $key;
    }

    /*
    */
    function init()
    {
        parent::init();
        
        $this->initDb();

        // base load
        $this->url = new UrlManager( $this ); // $this is controller  

    }


    function beforeAction($action)
    {
        SessionManager::init();
        return true;
    }

    function afterAction($action)
    {
        return true;
    }

    // --------------------------------------------------------------------------------
    //
    // --------------------------------------------------------------------------------

    // template base path
    public function getTemplatePath( $templateName=null, $pathType=null )
    {
        $basePath = UrlManager::getBasePath($pathType);
        if( $templateName ) {
            $templatePath = $basePath .'/templates/member/'. $this->themeName .'/'. $templateName;
        }
        else {
            $templatePath = $basePath .'/templates/member/'. $this->themeName;
        }
        return $templatePath;
    }

}